home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
basic
/
topmenu2.zip
/
TOPMENU2.BAS
< prev
next >
Wrap
BASIC Source File
|
1989-09-06
|
17KB
|
397 lines
SUB Top.Menu (sel, sel$(), fgc, bgc, hlc, topline, dis.time, dis.date, scn.blank, msg$, bgc$)
'========================================================================
'Initilize Routine Varables
'========================================================================
DIM a(20) ' maximum number of top selections allowed
month.data$ = "JanFebMarAprMayJunJulAugSepOctNovDec"
start: S$ = ""
a = 0
'========================================================================
' Clear The Screen Using The Character in bgc$
' Using The Colors Specified in fgc,bgc this will print the bgc$
' Character to all locations on the screen.
'========================================================================
COLOR fgc, bgc
FOR i = 1 TO 25
LOCATE i, 1
PRINT STRING$(80, bgc$);
NEXT
'========================================================================
'Initilize Line# 25 (The Help Line)
'This will init the Help Line to reverse colors specified in fgc,bgc.
'
'Line 25 is where the Help messages are displayed for the Selections
'
'The Message Strings are passed via the SEL$(x,10) string of each selection
'========================================================================
LOCATE 25, 1
COLOR bgc, fgc
PRINT SPACE$(80);
COLOR fgc, bgc
'========================================================================
'Read the Selection Names that where passed in array SEL$(x,0)
'Store the length of each one in the array A().
'Get the 1st character of each SEL$(x,0), and build a string of them,
'this string is used to make top row selections based on letters.
'Read them until SEL$(x,0) is a Nul (0) length.
'========================================================================
i = -1
DO
i = i + 1
a(i) = LEN(sel$(i, 0))
z$ = LTRIM$(sel$(i, 0))
S$ = S$ + UCASE$(LEFT$(z$, 1))
LOOP WHILE sel$(i, 0) <> ""
'========================================================================
' Setup the SEL variable to the correct value based on the number of
' selections that are to be displayed in the menu.
'========================================================================'
sel = i - 1
'========================================================================
' Print the Message thats in MSG$ on the top line of the menu.
' If no message (MSG$=""), then make top line a line
' else center the message in MSG$ on the top line.
'========================================================================
LOCATE topline + 1, 3
COLOR fgc, bgc
t = INT((75 - LEN(msg$)) / 2)
IF t * 2 + LEN(msg$) < 75 THEN f$ = STRING$((75 - (t * 2 + LEN(msg$))), "─") ELSE f$ = ""
PRINT "┌" + STRING$(t, "─") + msg$ + f$ + STRING$(t, "─") + "┐";
'========================================================================
'Initilize 2nd line of Menu
'Print blank line as 2nd line
'then display Selection Names on line 2
'The names are in array SEL$(x,0)
'========================================================================
LOCATE topline + 2, 2 'print blank line
COLOR 0, 0
PRINT " ";
COLOR fgc, bgc
PRINT "│" + SPACE$(75) + "│";
'-----------------------------------------------------------------
LOCATE topline + 2, 5 'print selection Names
COLOR fgc, bgc
FOR i = 0 TO sel
PRINT sel$(i, 0);
NEXT
'========================================================================
'Print 3rd line of Menu ( bottom of box)
'========================================================================
LOCATE topline + 3, 2
COLOR 0, 0
PRINT " ";
COLOR fgc, bgc
PRINT "└" + STRING$(75, "─") + "┘";
'========================================================================
' Setup varables
'========================================================================
subsel = 1
subnum = 1
zold = 2
S = 0
x = 5
'========================================================================
' Display submenu for the new Selection Name of SEL number
'========================================================================
GOSUB dis.sub
'========================================================================
'Display New Selection Name highlited on selection bar
'========================================================================'
lp: oldx = x 'update variables
x = 5
'-----------------------------------------------------------------
FOR i = 0 TO S 'Calculate new Selection position
x = x + LEN(sel$(i, 0))
NEXT
'-----------------------------------------------------------------
x = x - LEN(sel$(i - 1, 0)) 'fix x to equal location
'start of NEW selection Name
'-----------------------------------------------------------------
COLOR fgc, bgc 'put OLD selection Name back to
LOCATE topline + 2, oldx 'original color
PRINT sel$(olds, 0);
'-----------------------------------------------------------------
COLOR hlc, fgc 'Select NEW selection Name
LOCATE topline + 2, x 'with highlite color
PRINT sel$(S, 0);
'========================================================================
' Print the message for the New Selection Name centered on line 25
' The string is taken from SEL$(x,10)
' Based on the current value of S.
'========================================================================'
t = INT((80 - LEN(sel$(S, 10))) / 2)
IF t * 2 + LEN(sel$(S, 10)) < 78 THEN f$ = STRING$((78 - (t * 2 + LEN(sel$(S, 10)))), "─") ELSE f$ = ""
LOCATE 25, 1
COLOR bgc, fgc
PRINT SPACE$(t) + sel$(S, 10) + f$ + SPACE$(t);
COLOR fgc, bgc
'========================================================================'
' Wait for KEY to be pressed and....
' Display Current TIME if variable Dis.Time is not equal to 0.
' Display Current DATE if variable Dis.Date is not equal to 0.
' if screen blank is ON (scn.blank=1) then blank screen if no key is
' pressed for 3 minutes
'========================================================================'
get.key: blk.time = VAL(MID$(TIME$, 4, 2))
DO
a$ = INKEY$
'-----------------------------------------------------------------
IF dis.date = 0 THEN GOTO dtime 'Display Date
month$ = MID$(month.data$, (((VAL(DATE$) - 1) * 3) + 1), 3)
LOCATE topline + 1, 4
PRINT CHR$(16) + month$ + " " + MID$(DATE$, 4, 2) + "," + MID$(DATE$, 9, 2) + CHR$(17)
'-----------------------------------------------------------------
dtime: IF dis.time = 0 THEN GOTO chk.blank 'Display Time
tx = VAL(LEFT$(TIME$, 2))
am$ = "Am"
IF tx > 12 THEN tx = tx - 12: am$ = "Pm"
t$ = CHR$(16) + RIGHT$(STR$(tx), 2) + ":" + MID$(TIME$, 4, 2) + " " + am$ + CHR$(17)
LOCATE topline + 1, 69
PRINT t$
'-----------------------------------------------------------------
chk.blank: IF scn.blank = 0 THEN GOTO key.loop 'blank screen
IF VAL(MID$(TIME$, 4, 2)) > blk.time + 2 THEN GOTO blk.scrn
key.loop: LOOP WHILE a$ = ""
'========================================================================'
'Process the key that was pressed
'========================================================================''
IF LEN(a$) < 2 THEN GOTO reg.key 'if the key is an
'extended key (len>1)
'then process as cursor key
'else check for othe